/*
 * @Description: import.meta.glob批量导入路由
 * @Author: Chenx
 * @Date: 2023-03-03 15:58:34
 * @LastEditors: Chenx
 * @LastEditTime: 2023-03-17 17:38:03
 */
import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
export const routes: RouteRecordRaw[] = []
// 根据路径拿到所有modules文件夹下的ts文件
const metaRouters:Record<string, any > = import.meta.glob("./modules/*.ts", { eager: true })
// * 处理路由表
Object.keys(metaRouters).forEach(item => {
  Object.keys(metaRouters[item]).forEach((key: any) => {
    routes.push(...metaRouters[item][key])
  })
})

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router